home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / vlapak1.zip / VLA_FONT.ZIP / HSCRCYCL.ASM < prev    next >
Assembly Source File  |  1993-09-28  |  10KB  |  406 lines

  1.     IDEAL
  2.     DOSSEG
  3.     MODEL SMALL
  4.     STACK 200h
  5.     CODESEG
  6.     p386
  7.     
  8.     ASSUME CS:@CODE, DS:@CODE
  9. ────────────────────────────────────────────────────────────────────────────
  10. STRUC VCHHDR
  11.     Ident   db  "VLACH"
  12.     From    db  ?
  13.     X       db  ?
  14.     Y       db  ?
  15.     NumChar db  ?
  16. ENDS
  17.  
  18. STRUC Pal
  19.     R       db  ?
  20.     G       db  ?
  21.     B       db  ?
  22. ENDS
  23. ────────────────────────────────────────────────────────────────────────────
  24. INCLUDE "MODEX.INC"
  25.  
  26. FileName_VCH    db      "palFont.VCH",0
  27. FileName_PAL    db      "palFont.PAL",0
  28.  
  29. Seg_VCH         dw      0
  30.  
  31. Palette         Pal     256 dup (<>)
  32. VCHHEADER       VCHHDR  <>
  33. CharWidths      db      256 dup (0)
  34.  
  35. TheMessage      db      "  WOW!! THIS SCROLLER LOOKS REALLY COMPLICATED! "
  36.                 db      "  BUT IT ISN'T..  IT'S A PALETTE ROTATE AND A "
  37.                 db      "SCROLLER.  KINDA WEIRD, EH?  "
  38.                 db      "  RESOLUTION IS: 256X200 PLANAR WITH A CELL HEIGHT "
  39.                 db      "OF 1 (2 SCAN LINES PER PIXEL) AND THE VIRTUAL WIDTH "
  40.                 db      "IS 520 PIXELS (2X256 + 8, TO HIDE THE AREA THAT'S BEING "
  41.                 db      "WORKED ON)          "
  42.                 db      0
  43.  
  44. MsgOff          dw      offset TheMessage
  45. CharOff         dw      0       ;offset to current column to draw of chr
  46. XYsize          dw      ?       ;number of bytes in a char
  47. CurColumn       db      1
  48. DestOff         dw      0
  49. SCReenWidth     =       130
  50. ────────────────────────────────────────────────────────────────────────────
  51.     Numcolors   dw  8     ;# of colors to rotate
  52.     NumColors3  dw  8*3   ;# of colors*3
  53.     StartAt     db  2       ;color to start rotate at
  54.     PalIndex    dw  0       ;color to start write at- increased every time
  55.                             ;to produce the rotating effect
  56.     PalIndexVel dw  1       ;amount PalIndex Changes for each screen
  57.  
  58.     PalOffset   dw  offset Palette + 6
  59. ────────────────────────────────────────────────────────────────────────────
  60. PROC RotatePalette NEAR
  61.     pusha
  62.  
  63.     call  WritePalette
  64.  
  65.     mov   ax,[PalIndexVel]
  66.     add   [PalIndex],ax    ;change the palette index
  67.  
  68.     mov   ax,[PalIndex]    ;are we over the number of colors?
  69.     mov   bx,[NumColors]
  70.  
  71.     cmp   ax,bx
  72.     jl    NotTooHigh
  73.     sub   [PalIndex],bx    ;add [Numcolors] to the index
  74.     jmp   NotTooLow
  75. NotTooHigh:
  76.     cmp   ax,0
  77.     jge   NotTooLow
  78.     add   [PalIndex],bx    ;subtract [Numcolors] to the index
  79. NotTooLow:
  80.  
  81.     popa
  82.     ret
  83. ENDP
  84.  
  85. PROC WritePalette NEAR        
  86.     cld
  87.  
  88.     mov   dx,[PalIndex]
  89.     mov   bx,dx
  90.     add   bx,bx           ;This just multiplies
  91.     add   bx,dx           ;bx by three ( bx = bx + 2*bx )
  92.  
  93.     mov   si,[PalOffset]
  94.     mov   dx,03c8h
  95.     mov   ax,[PalIndex]
  96.     add   al,[StartAt]
  97.     out   dx,al           ;start writing at [PalIndex]+[StartAt]
  98.     inc   dx
  99.     mov   cx,[NumColors3]
  100.     sub   cx,bx           ;get the number of colors to write
  101.     rep outsb
  102.  
  103.     mov   al,[StartAt]
  104.     dec   dx              ;point to palette index
  105.     out   dx,al           ;out the number we want to start writing at 
  106.     inc   dx
  107.     mov   cx,bx           ;get the number of colors to write
  108.     rep outsb             ;note that SI is already where we want it
  109.  
  110.     ret
  111. ENDP         ;well, that's all there is to it
  112.  
  113.     ────────────────────────────────────────────────────────────────────
  114.     ; Load in the font named in FileName_VCH and loads in the Palette
  115.     ; named in FileName_PAL. 
  116.     ;
  117.     ; Returns CF = 1 if there was an error
  118.     ────────────────────────────────────────────────────────────────────
  119. PROC LoadFont NEAR
  120.     pusha
  121.     push    ds
  122.  
  123.     mov     ax,cs
  124.     mov     ds,ax
  125.     mov     dx,offset FileName_PAL      ;open the palette file
  126.     mov     ax,3d00h
  127.     int     21h
  128.     jc      @@Error
  129.     mov     bx,ax
  130.  
  131.     mov     dx,offset Palette           ;read in the palette
  132.     mov     cx,768
  133.     mov     ah,3fh
  134.     int     21h
  135.  
  136.     mov     ah,3eh                      ;close PAL file
  137.     int     21h
  138.  
  139.     mov     dx,offset FileName_VCH      ;open VCH file
  140.     mov     ax,3d00h
  141.     int     21h
  142.     jc      @@Error
  143.     mov     bx,ax
  144.  
  145.     mov     dx,offset VCHHeader         ;load in the header
  146.     mov     cx,size VCHHDR
  147.     mov     ah,3fh
  148.     int     21h
  149.  
  150.     mov     al,[VCHHEADER.X]            ;calc data size
  151.     mul     [VCHHEADER.Y]
  152.     mov     [XYsize],ax
  153.     movzx   cx,[VCHHEADER.NumChar]
  154.     mul     cx
  155.     mov     cx,ax
  156.  
  157.     mov     ax,[cs:SEG_VCH]             ;move SEG_VCH into DS, but be sure
  158.     or      ax,ax                       ;the segment isn't 0
  159.     stc
  160.     je      @@Error
  161.     mov     ds,ax
  162.     xor     dx,dx                       ;load in the data
  163.     mov     ah,3fh
  164.     int     21h
  165.  
  166.     mov     ax,cs
  167.     mov     ds,ax
  168.     mov     dx,offset CharWidths
  169.     movzx   cx,[VCHheader.NumChar]
  170.     mov     ah,3fh
  171.     int     21h                         ;read in widths of chars
  172.  
  173.     mov     ah,3eh                      ;close VCH file
  174.     int     21h
  175.     clc
  176.  
  177. @@Error:
  178.  
  179.     pop     ds
  180.     popa
  181.     ret
  182. ENDP
  183.     ────────────────────────────────────────────────────────────────────
  184.     ;Starts the next letter in the message
  185.     ────────────────────────────────────────────────────────────────────
  186. PROC NewChar NEAR
  187.     pusha
  188.     push    ds
  189.     mov     ax,cs
  190.     mov     ds,ax
  191.  
  192.     mov     si,[MsgOff]     ;get the offset to the next char
  193. @@MsgLoop:
  194.     lodsb
  195.     or      al,al
  196.     jne     @@IsaChar
  197.     mov     si,offset TheMessage
  198.     jmp short @@MsgLoop
  199.  
  200. @@IsaChar:
  201.     mov     ah,[VCHHEADer.From]
  202.     add     ah,[VCHHEADer.NumChar]
  203.     cmp     al,[VCHHEADer.FROM]
  204.     jb      @@MsgLoop
  205.     cmp     al,ah
  206.     ja      @@MsgLoop
  207.  
  208.     mov     [MsgOff],si
  209.     sub     al,[VCHheader.From]
  210.     movzx   ax,al
  211.     mov     bx,ax
  212.     mul     [XYsize]
  213.     mov     [CharOff],ax
  214.     
  215.     mov     al,[CharWidths + bx]
  216.     mov     [CurColumn],al
  217.     
  218.     pop     ds
  219.     popa
  220.     ret
  221. ENDP
  222.     ────────────────────────────────────────────────────────────────────
  223.     ; Draws the Next column onto the screen, calls NewChar if done with
  224.     ; current character
  225.     ────────────────────────────────────────────────────────────────────
  226. PROC DrawColumn NEAR
  227.     pusha
  228.     push    ds es fs
  229.     mov     ax,cs
  230.     mov     ds,ax
  231.  
  232.     mov     bx,[DestOff]
  233.     add     bx,2
  234.     @Set_Start_Offset
  235.  
  236.     ;dec     [CurColumn]
  237.     sub     [CurColumn],4
  238.     jg      @@NoNew
  239.  
  240.     call    NewChar
  241.  
  242. @@NoNew:
  243.     mov     fs,[SEG_VCH]
  244.     mov     es,[VGASEG]
  245.  
  246.     mov     bp,SCReenWidth         ;screen width
  247.  
  248.     mov     dx,SC_Index
  249.     mov     ax,0102h
  250.     out     dx,ax
  251.  
  252.     movzx   dx,[VCHheader.X]
  253.     movzx   cx,[VCHheader.Y]
  254.     mov     si,[CharOff]    ;fs:si points to the data
  255.     mov     di,[DestOff]
  256. @@Zloop:
  257.     mov     al,[fs:si]
  258.     mov     [es:di],al
  259.     mov     [es:di+SCReenWidth/2],al
  260.     add     di,bp
  261.  
  262.     add     si,dx
  263.  
  264.     loop    @@ZLoop
  265.     
  266.     mov     dx,SC_Index
  267.     mov     ax,0202h
  268.     out     dx,ax
  269.  
  270.     movzx   dx,[VCHheader.X]
  271.     movzx   cx,[VCHheader.Y]
  272.     mov     si,[CharOff]    ;fs:si points to the data
  273.     inc     si
  274.     mov     di,[DestOff]
  275. @@Zloop2:
  276.     mov     al,[fs:si]
  277.     mov     [es:di],al
  278.     mov     [es:di+SCReenWidth/2],al
  279.     add     di,bp
  280.  
  281.     add     si,dx
  282.  
  283.     loop    @@ZLoop2
  284.     
  285.     mov     dx,SC_Index
  286.     mov     ax,0402h
  287.     out     dx,ax
  288.  
  289.     movzx   dx,[VCHheader.X]
  290.     movzx   cx,[VCHheader.Y]
  291.     mov     si,[CharOff]    ;fs:si points to the data
  292.     add     si,2
  293.     mov     di,[DestOff]
  294. @@Zloop3:
  295.     mov     al,[fs:si]
  296.     mov     [es:di],al
  297.     mov     [es:di+SCReenWidth/2],al
  298.     add     di,bp
  299.  
  300.     add     si,dx
  301.  
  302.     loop    @@ZLoop3
  303.  
  304.     mov     dx,SC_Index
  305.     mov     ax,0802h
  306.     out     dx,ax
  307.  
  308.     movzx   dx,[VCHheader.X]
  309.     movzx   cx,[VCHheader.Y]
  310.     mov     si,[CharOff]    ;fs:si points to the data
  311.     add     si,3
  312.     mov     di,[DestOff]
  313. @@Zloop4:
  314.     mov     al,[fs:si]
  315.     mov     [es:di],al
  316.     mov     [es:di+SCReenWidth/2],al
  317.     add     di,bp
  318.  
  319.     add     si,dx
  320.  
  321.     loop    @@ZLoop4
  322.  
  323.     inc     [DestOff]
  324.     cmp     [DestOff],ScreenWidth/2
  325.     jb      @@okok
  326.  
  327.     mov     [DestOff],0
  328.  
  329. @@okok:
  330.     add     [CharOff],4
  331.  
  332.     pop     fs es ds
  333.     popa
  334.     ret
  335. ENDP
  336.  
  337. HPPPOS  db  0
  338.  
  339. PROC Scrollit NEAR
  340.     pusha
  341.  
  342.     mov     ah,[HPPpos]
  343.     add     ah,2 *2
  344.     mov     [HPPpos],ah
  345.     cmp     ah,8
  346.     jb      @@JustSetIt
  347.     sub     ah,8
  348.     mov     [HPPpos],ah
  349.  
  350.     call    DrawColumn
  351.  
  352. @@JustSetIt:
  353.     mov     ah,[HPPpos]
  354.     @Set_HPP
  355.  
  356.     popa
  357.     ret
  358. ENDP
  359. ────────────────────────────────────────────────────────────────────────────
  360. START:
  361.     mov     ax,cs
  362.     mov     ds,ax
  363.  
  364.     mov     ax,ss
  365.     mov     bx,sp
  366.     add     bx,15
  367.     shr     bx,4
  368.     add     ax,bx
  369.     mov     [SEG_VCH],ax
  370.  
  371.     @SetModeX m256x200x256, 520
  372.  
  373.     call    LoadFont
  374.     mov     si,offset Palette
  375.     mov     cx,256
  376.     mov     al,0
  377.     @WritePalette
  378.     
  379.     mov     dx,CRTC_Index
  380.     mov     al,9
  381.     mov     ah,1    ;each dot is 2 high (use HEIGHT-1)
  382.     out     dx,ax
  383.  
  384.     @SET_PPC    ;set Pixel Panning Compatibility
  385.                 ;so the split screen, if I had one, would not be disturbed.
  386.                 
  387. @@MainLoop:
  388.     @FullVertWait
  389.     call    RotatePalette
  390.     call    Scrollit
  391.  
  392.     ;call    DrawColumn
  393.  
  394.     mov     ah,1
  395.     int     16h
  396.     jz      @@MainLoop
  397.  
  398.     mov     ah,0
  399.     int     16h
  400.  
  401.     mov     ax,3
  402.     int     10h
  403.     mov     ax,4c00h
  404.     int     21h
  405. END START
  406.